package logic

import (
	"bw-renting/api/internal/svc"
	"bw-renting/api/internal/types"
	"bw-renting/user-rpc/userclient"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoLogic {
	return &UserInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// TODO: 获取用户信息
func (l *UserInfoLogic) UserInfo(req *types.GetUserInfoReq) (resp *types.Data, err error) {
	// todo: add your logic here and delete this line
	d, _ := l.svcCtx.UserServer.UserInfoRequest(l.ctx, &userclient.GetUserInfoReq{
		UserID: int64(req.UserId),
	})
	return &types.Data{
		Code:    int(d.Code),
		Message: d.Message,
	}, nil
}
